home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / OpenTransport / Interfaces / PInterfaces / OpenTptInternet.p < prev    next >
Encoding:
Text File  |  1996-11-21  |  9.2 KB  |  313 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OpenTptInternet.p
  3.  
  4.      Contains:    Public TCP/IP definitions
  5.  
  6.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9. }
  10. {$IFC UNDEFINED UsingIncludes}
  11. {$SETC UsingIncludes := 0}
  12. {$ENDC}
  13.  
  14. {$IFC NOT UsingIncludes}
  15.  UNIT OpenTptInternet;
  16.  INTERFACE
  17. {$ENDC}
  18.  
  19. {$IFC UNDEFINED __OPENTPTINTERNET__}
  20. {$SETC __OPENTPTINTERNET__ := 1}
  21.  
  22. {$I+}
  23. {$SETC OpenTptInternetIncludes := UsingIncludes}
  24. {$SETC UsingIncludes := 1}
  25.  
  26. {$IFC UNDEFINED __OPENTRANSPORT__}
  27. {$I OpenTransport.p}
  28. {$ENDC}
  29.  
  30. {$PUSH}
  31. {$ALIGN MAC68K}
  32. {$LibExport+}
  33.  
  34. {
  35. ******************************************************************************
  36. ** Misc 
  37. *******************************************************************************
  38. }
  39.  
  40. TYPE
  41.     InetPort                            = UInt16;
  42.     InetHost                            = UInt32;
  43. {     Enums used as address type designations. }
  44.  
  45. CONST
  46.     AF_INET                        = 2;                            {  Traditonal }
  47.     AF_DNS                        = 42;                            {  Obviously, the answer to... }
  48.  
  49. {
  50.     Enum which can be used to bind to all IP interfaces
  51.     rather than a specific one.
  52. }
  53.     kOTAnyInetAddress            = 0;                            {  Wildcard }
  54.  
  55.  
  56. TYPE
  57.     InetSvcRef                            = Ptr;
  58. {
  59. ******************************************************************************
  60. ** XTI Options
  61. *******************************************************************************
  62. }
  63. {  Protocol levels }
  64.  
  65. CONST
  66.     INET_IP                        = $00;
  67.     INET_TCP                    = $06;
  68.     INET_UDP                    = $11;
  69.  
  70. {
  71. ******************************************************************************
  72. ** Some prefixes for shared libraries
  73. *******************************************************************************
  74. }
  75. {
  76. ******************************************************************************
  77. ** Module Names
  78. *******************************************************************************
  79. }
  80.     kDNRName        =    'dnr';
  81.     kTCPName        =    'tcp';
  82.     kUDPName        =    'udp';
  83.     kRawIPName    =    'rawip';
  84. {
  85. ******************************************************************************
  86. ** Options
  87. *******************************************************************************
  88. }
  89. {  TCP Level Options }
  90.     TCP_NODELAY                    = $01;
  91.     TCP_MAXSEG                    = $02;
  92.     TCP_NOTIFY_THRESHOLD        = $10;                            { * not a real XTI option  }
  93.     TCP_ABORT_THRESHOLD            = $11;                            { * not a real XTI option  }
  94.     TCP_CONN_NOTIFY_THRESHOLD    = $12;                            { * not a real XTI option  }
  95.     TCP_CONN_ABORT_THRESHOLD    = $13;                            { * not a real XTI option  }
  96.     TCP_OOBINLINE                = $14;                            { * not a real XTI option  }
  97.     TCP_URGENT_PTR_TYPE            = $15;                            { * not a real XTI option  }
  98.     TCP_KEEPALIVE                = $08;                            {  keepalive defined in OpenTransport.h  }
  99.     T_GARBAGE                    = 2;
  100.  
  101. {  UDP Level Options }
  102.     UDP_CHECKSUM                = $0600;
  103.     UDP_RX_ICMP                    = $02;
  104.  
  105. {  IP Level Options }
  106.     IP_OPTIONS                    = $01;
  107.     IP_TOS                        = $02;
  108.     IP_TTL                        = $03;
  109.     IP_REUSEADDR                = $04;
  110.     IP_DONTROUTE                = $10;
  111.     IP_BROADCAST                = $20;
  112.     IP_HDRINCL                    = $1002;
  113.     IP_RCVOPTS                    = $1005;
  114.     IP_RCVDSTADDR                = $1007;
  115.     IP_MULTICAST_IF                = $1010;                        {  set/get IP multicast interface     }
  116.     IP_MULTICAST_TTL            = $1011;                        {  set/get IP multicast timetolive     }
  117.     IP_MULTICAST_LOOP            = $1012;                        {  set/get IP multicast loopback     }
  118.     IP_ADD_MEMBERSHIP            = $1013;                        {  add an IP group membership         }
  119.     IP_DROP_MEMBERSHIP            = $1014;                        {  drop an IP group membership         }
  120.     IP_BROADCAST_IF                = $1015;                        {  Set interface for broadcasts      }
  121.     IP_RCVIFADDR                = $1016;                        {  Set interface for broadcasts      }
  122.  
  123. {     DVMRP-specific setsockopt commands, from ip_mroute.h }
  124.     DVMRP_INIT                    = $64;
  125.     DVMRP_DONE                    = $65;
  126.     DVMRP_ADD_VIF                = $66;
  127.     DVMRP_DEL_VIF                = $67;
  128.     DVMRP_ADD_LGRP                = $68;
  129.     DVMRP_DEL_LGRP                = $69;
  130.     DVMRP_ADD_MRT                = $6A;
  131.     DVMRP_DEL_MRT                = $6B;
  132.  
  133. {  IP_TOS precdence levels }
  134.     T_ROUTINE                    = 0;
  135.     T_PRIORITY                    = 1;
  136.     T_IMMEDIATE                    = 2;
  137.     T_FLASH                        = 3;
  138.     T_OVERRIDEFLASH                = 4;
  139.     T_CRITIC_ECP                = 5;
  140.     T_INETCONTROL                = 6;
  141.     T_NETCONTROL                = 7;
  142.  
  143. {     IP_TOS type of service }
  144.     T_NOTOS                        = $00;
  145.     T_LDELAY                    = $10;
  146.     T_HITHRPT                    = $08;
  147.     T_HIREL                        = $04;
  148.  
  149. {  IP Multicast option structures }
  150.  
  151. TYPE
  152.     TIPAddMulticastPtr = ^TIPAddMulticast;
  153.     TIPAddMulticast = RECORD
  154.         multicastGroupAddress:    InetHost;
  155.         interfaceAddress:        InetHost;
  156.     END;
  157.  
  158. {
  159. ******************************************************************************
  160. ** Protocol-specific events
  161. *******************************************************************************
  162. }
  163.  
  164. CONST
  165.     T_DNRSTRINGTOADDRCOMPLETE    = $10000001;
  166.     T_DNRADDRTONAMECOMPLETE        = $10000002;
  167.     T_DNRSYSINFOCOMPLETE        = $10000003;
  168.     T_DNRMAILEXCHANGECOMPLETE    = $10000004;
  169.     T_DNRQUERYCOMPLETE            = $10000005;
  170.  
  171. {
  172. ******************************************************************************
  173. ** InetAddress
  174. *******************************************************************************
  175. }
  176.  
  177. TYPE
  178.     InetAddressPtr = ^InetAddress;
  179.     InetAddress = RECORD
  180.         fAddressType:            OTAddressType;                            {  always AF_INET }
  181.         fPort:                    InetPort;                                {  Port number  }
  182.         fHost:                    InetHost;                                {  Host address in net byte order }
  183.         fUnused:                PACKED ARRAY [0..7] OF UInt8;            {  Traditional unused bytes }
  184.     END;
  185.  
  186. {
  187. ******************************************************************************
  188. ** Domain Name Resolver (DNR) 
  189. *******************************************************************************
  190. }
  191.  
  192. CONST
  193.     kMaxHostAddrs                = 10;
  194.     kMaxSysStringLen            = 32;
  195.     kMaxHostNameLen                = 255;
  196.  
  197.  
  198. TYPE
  199.     InetDomainName                        = PACKED ARRAY [0..255] OF CHAR;
  200.     InetHostInfoPtr = ^InetHostInfo;
  201.     InetHostInfo = RECORD
  202.         name:                    InetDomainName;
  203.         addrs:                    ARRAY [0..9] OF InetHost;
  204.     END;
  205.  
  206.     InetSysInfoPtr = ^InetSysInfo;
  207.     InetSysInfo = RECORD
  208.         cpuType:                PACKED ARRAY [0..31] OF CHAR;
  209.         osType:                    PACKED ARRAY [0..31] OF CHAR;
  210.     END;
  211.  
  212.     InetMailExchangePtr = ^InetMailExchange;
  213.     InetMailExchange = RECORD
  214.         preference:                UInt16;
  215.         exchange:                InetDomainName;
  216.     END;
  217.  
  218.     DNSQueryInfoPtr = ^DNSQueryInfo;
  219.     DNSQueryInfo = RECORD
  220.         qType:                    UInt16;
  221.         qClass:                    UInt16;
  222.         ttl:                    UInt32;
  223.         name:                    InetDomainName;
  224.         responseType:            UInt16;                                    {  answer, authority, or additional }
  225.         resourceLen:            UInt16;                                    {  actual length of array which follows }
  226.         resourceData:            PACKED ARRAY [0..3] OF CHAR;            {  size varies }
  227.     END;
  228.  
  229. {
  230. ******************************************************************************
  231. ** DNSAddress
  232. **
  233. **        The DNSAddress format is optional and may be used in connects,
  234. **        datagram sends, and resolve address calls.   The name takes the 
  235. **        format "somewhere.com" or "somewhere.com:portnumber" where
  236. **        the ":portnumber" is optional.   The length of this structure
  237. **        is arbitrarily limited to the overall max length of a domain
  238. **        name (255 chars), although a longer one can be use successfully
  239. **        if you use this as a template for doing so.   However, the domain name 
  240. **        is still limited to 255 characters.
  241. *******************************************************************************
  242. }
  243.     DNSAddressPtr = ^DNSAddress;
  244.     DNSAddress = RECORD
  245.         fAddressType:            OTAddressType;                            {  always AF_DNS }
  246.         fName:                    InetDomainName;
  247.     END;
  248.  
  249. {
  250. ******************************************************************************
  251. ** InetInterfaceInfo
  252. *******************************************************************************
  253. }
  254.     InetInterfaceInfoPtr = ^InetInterfaceInfo;
  255.     InetInterfaceInfo = RECORD
  256.         fAddress:                InetHost;
  257.         fNetmask:                InetHost;
  258.         fBroadcastAddr:            InetHost;
  259.         fDefaultGatewayAddr:    InetHost;
  260.         fDNSAddr:                InetHost;
  261.         fVersion:                UInt16;
  262.         fHWAddrLen:                UInt16;
  263.         fHWAddr:                Ptr;
  264.         fIfMTU:                    UInt32;
  265.         fReservedPtrs:            ARRAY [0..1] OF Ptr;
  266.         fDomainName:            InetDomainName;
  267.         fReserved:                PACKED ARRAY [0..255] OF UInt8;
  268.     END;
  269.  
  270. {
  271. ******************************************************************************
  272. ** Static helper functions
  273. *******************************************************************************
  274. }
  275. PROCEDURE OTInitInetAddress(VAR addr: InetAddress; port: InetPort; host: InetHost);
  276. FUNCTION OTInitDNSAddress(VAR addr: DNSAddress; str: CStringPtr): size_t;
  277. FUNCTION OTInetStringToHost(str: CStringPtr; VAR host: InetHost): OSStatus;
  278. PROCEDURE OTInetHostToString(host: InetHost; str: CStringPtr);
  279. FUNCTION OTInetGetInterfaceInfo(VAR info: InetInterfaceInfo; val: SInt32): OSStatus;
  280. {
  281. ******************************************************************************
  282. ** InetServices & DNR calls
  283. *******************************************************************************
  284. }
  285.  
  286. CONST
  287.     kDefaultInternetServicesPath = -3;
  288.  
  289. {$IFC NOT OTKERNEL }
  290. FUNCTION OTOpenInternetServices(cfig: OTConfigurationPtr; oflag: OTOpenFlags; VAR err: OSStatus): InetSvcRef;
  291. FUNCTION OTAsyncOpenInternetServices(cfig: OTConfigurationPtr; oflag: OTOpenFlags; proc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  292. FUNCTION OTInetStringToAddress(ref: InetSvcRef; name: CStringPtr; VAR hinfo: InetHostInfo): OSStatus;
  293. FUNCTION OTInetAddressToName(ref: InetSvcRef; addr: InetHost; VAR name: InetDomainName): OSStatus;
  294. FUNCTION OTInetSysInfo(ref: InetSvcRef; name: CStringPtr; VAR sysinfo: InetSysInfo): OSStatus;
  295. FUNCTION OTInetMailExchange(ref: InetSvcRef; name: CStringPtr; VAR num: UInt16; mx: InetMailExchangePtr): OSStatus;
  296. FUNCTION OTInetQuery(ref: InetSvcRef; name: CStringPtr; qClass: UInt16; qType: UInt16; buf: CStringPtr; buflen: size_t; VAR argv: UNIV Ptr; argvlen: size_t; flags: OTFlags): OSStatus;
  297.  
  298. CONST
  299.     kDefaultInetInterface        = -1;
  300.     kInetInterfaceInfoVersion    = 2;
  301.  
  302. {$ENDC}
  303. {$ALIGN RESET}
  304. {$POP}
  305.  
  306. {$SETC UsingIncludes := OpenTptInternetIncludes}
  307.  
  308. {$ENDC} {__OPENTPTINTERNET__}
  309.  
  310. {$IFC NOT UsingIncludes}
  311.  END.
  312. {$ENDC}
  313.